Login and get codingHow about writing a queue that holds the last 5 items?
Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first. A real-world example of queue can be a single-lane one-way road, where the vehicle enters first, exits first. More real-world examples can be seen as queues at the ticket windows and bus-stops. [source]Complete the
my_queue
function to return a queue-like data type that keeps the lastn
items.Check the standard library to see how you can do this in the shortest/most efficient way.
See an example output below and the tests that check for various values of
n
. Have fun!
799 out of 818 users completed this Bite.
Will you be the 800th person to crack this Bite?
Resolution time: ~38 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.11 on a 1-10 difficulty scale.
» Up for a challenge? 💪